package com.biglead.demo.rabbit;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OrderRabbitMQTopicConfig {

    private static final String QUEUE = "seckillQueue";
    private static final String EXCHANGE = "seckillExchange";


    @Bean
    public Queue seckillQueue() {
        return new Queue(QUEUE);
    }

    @Bean
    public TopicExchange seckillExchange() {
        return new TopicExchange(EXCHANGE);
    }


    @Bean
    public Binding binding() {
        return BindingBuilder.bind(seckillQueue()).to(seckillExchange()).with("seckill.#");
    }


    /**
     * ---------------------------------------------普通订单使用的消息队列-----------------------------------------------------------
     */

    private static final String commonOrderQueue = "commonOrderQueue";
    private static final String commonExchange = "commonOrderExchange";

    @Bean
    public Queue commonOrderQueue() {
        return new Queue(commonOrderQueue);
    }
    @Bean
    public TopicExchange commonExchange() {
        return new TopicExchange(commonExchange);
    }
    @Bean
    public Binding commonOrderBinding() {
        return BindingBuilder.bind(commonOrderQueue()).to(commonExchange()).with("commonOrder.#");
    }

}
